package club.vann.kafka.mock.service;

import club.vann.kafka.mock.kafka.KafkaProducer;
import com.cyberx.lunyu.Framework;
import com.cyberx.lunyu.PriceDirectionOuterClass;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
public class PriceDirectionService {
  private final KafkaProducer kafkaProducer;

  public void send() {
    String strategySpec = "aaa";
    PriceDirectionOuterClass.PriceDirection priceDirection =
        PriceDirectionOuterClass.PriceDirection.newBuilder()
            .setSymbol("SYMBOL")
            .setErrorCode(Framework.ErrorCode.newBuilder().build())
            .setTimestamp(Framework.TimestampRecord.newBuilder().build())
            .setDeltaInBps(1D)
            .setDirection("UP4")
            .setSourcePrice1(2D)
            .setSourcePrice2(3D)
            .setRsa(4D)
            .setRsm(5D)
            .setFma2(6D)
            .setSma2(7D)
            .setPrice(8D)
            .setThresholdBps(9D)
            .setStrategySpec(strategySpec)
            .setTicker("BTC/USDT")
            .setVenue("")
            .build();
    this.kafkaProducer.send(
        "zhongyong.price.moving.average.direction.output",
        strategySpec,
        priceDirection.toByteArray());
  }
}
